import mmm_pyton
import plotly.graph_objects as go
import pandas as pd
import numpy as np
import statsmodels.api as sm
import math
from sklearn.base import BaseEstimator, TransformerMixin
from lmfit import Parameters, Minimizer, report_fit, Parameters
from sklearn.metrics import r2_score, mean_squared_error, median_absolute_error
import os
import json
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.api as sm
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler, LabelBinarizer
from sklearn.pipeline import Pipeline
from sklearn.linear_model import Lasso, Ridge, LinearRegression, ElasticNet
from sklearn.metrics import r2_score, mean_squared_error, median_absolute_error
from sklearn_pandas import DataFrameMapper, gen_features
from lmfit import Parameters, Minimizer, report_fit, Parameters
from scipy.optimize import minimize, Bounds, LinearConstraint
import random
dataset = pd.read_csv('Media_data.csv', sep = ';').dropna()
dataset
| Week | Sales | Brand_price | Average_category_price | TV_1 | TV_2 | TV_3 | TV_4 | TV_5 | TV_6 | TV_7 | TV_8 | TV_9 | TV_competitor_1 | TV_competitor_2 | TV_competitor_3 | TV_competitor_4 | Press | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 04.01.2010 | 7092.0 | 55 | 104 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 11.01.2010 | 8664.0 | 52 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 2 | 18.01.2010 | 7526.0 | 53 | 97 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 50 |
| 3 | 25.01.2010 | 9165.0 | 55 | 103 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 56 |
| 4 | 01.02.2010 | 8713.0 | 52 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 134 | 30.07.2012 | 9294.0 | 90 | 145 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 135 | 06.08.2012 | 9105.0 | 93 | 142 | 0 | 5 | 0 | 0 | 0 | 0 | 0 | 13 | 0 | 0 | 14 | 0 | 0 | 30 |
| 136 | 13.08.2012 | 9135.0 | 90 | 141 | 0 | 9 | 0 | 0 | 0 | 0 | 0 | 15 | 0 | 0 | 15 | 0 | 0 | 53 |
| 137 | 20.08.2012 | 9503.0 | 89 | 139 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 0 | 0 | 25 |
| 138 | 27.08.2012 | 8983.0 | 89 | 142 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 0 | 0 | 14 |
139 rows × 18 columns
dataset['Week'] = pd.to_datetime(df['Week'])
month = df.groupby(df['Week'].dt.strftime('%B-%Y'))['Sales'].mean().sort_values()
print(round(month))
Week May-2010 7188.0 July-2010 7661.0 March-2010 7744.0 April-2010 7880.0 February-2010 8057.0 September-2010 8070.0 June-2010 8552.0 November-2012 8850.0 January-2010 9031.0 April-2012 9037.0 August-2010 9042.0 August-2012 9207.0 July-2012 9268.0 May-2012 9343.0 June-2012 9698.0 October-2010 9892.0 June-2011 9908.0 November-2010 10044.0 December-2010 10164.0 September-2011 10352.0 February-2012 10417.0 March-2012 10609.0 September-2012 10850.0 December-2011 11005.0 May-2011 11213.0 July-2011 11804.0 August-2011 11835.0 November-2011 11861.0 January-2012 11899.0 February-2011 12132.0 April-2011 12251.0 January-2011 12914.0 December-2012 13169.0 October-2011 13192.0 March-2011 13382.0 Name: Sales, dtype: float64
import warnings
warnings.filterwarnings('ignore')
import seaborn as sns
dataset['Brand_price'].corr(dataset['Average_category_price'])
0.9361923528387466
sns.distplot(dataset['Brand_price'], hist = False, kde = True,
kde_kws = {'shade': True, 'linewidth': 3})
sns.distplot(dataset['Average_category_price'], hist = False, kde = True,
kde_kws = {'shade': True, 'linewidth': 3})
<AxesSubplot:xlabel='Average_category_price', ylabel='Density'>
price = df.groupby(df['Week'].dt.strftime('%Y-%m'))['Sales'].mean()
pricenew = price[:24]
pricenew.plot.bar()
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-3-b596aabfc2df> in <module> ----> 1 pricenew.plot.bar() NameError: name 'pricenew' is not defined
price1 = df.groupby(df['Week'].dt.to_period('Q'))['Sales'].mean()
price1
Week 2010Q1 8358.583333 2010Q2 7872.857143 2010Q3 8424.230769 2010Q4 10054.923077 2011Q1 12853.307692 2011Q2 11130.923077 2011Q3 11451.000000 2011Q4 12091.857143 2012Q1 10856.272727 2012Q2 9359.166667 2012Q3 9724.100000 2012Q4 11009.500000 Freq: Q-DEC, Name: Sales, dtype: float64
price1.plot.bar()
<AxesSubplot:xlabel='Week'>
price2 = df.groupby(df['Week'].dt.to_period('w'))['Sales'].mean()
price2
Week
2009-12-28/2010-01-03 8933.5
2010-01-11/2010-01-17 10599.0
2010-01-18/2010-01-24 7526.0
2010-01-25/2010-01-31 9165.0
2010-02-08/2010-02-14 7779.0
...
2012-08-20/2012-08-26 9503.0
2012-08-27/2012-09-02 10579.0
2012-09-03/2012-09-09 10187.0
2012-11-05/2012-11-11 8850.0
2012-12-03/2012-12-09 13169.0
Freq: W-SUN, Name: Sales, Length: 119, dtype: float64
Q1 = price2[1:10]
Q1.plot.bar()
<AxesSubplot:xlabel='Week'>
Q2 = price2[10:21]
Q2.plot.bar()
<AxesSubplot:xlabel='Week'>
Q3 = price2[21:33]
Q3.plot.bar()
<AxesSubplot:xlabel='Week'>
Q4 = price2[33:45]
Q4.plot.bar()
<AxesSubplot:xlabel='Week'>
OLS
import statsmodels.formula.api as smf
ac = smf.ols(formula = 'Sales ~ Brand_price + Average_category_price + TV_1 + TV_2 + TV_3 + TV_4 + TV_5 + TV_6 + TV_7 + TV_8 + TV_9 + TV_competitor_1 + TV_competitor_2 + TV_competitor_3 + TV_competitor_4 + Press ', data=dataset).fit()
ac.params
Intercept 2271.715702 Brand_price 14.394308 Average_category_price 46.549117 TV_1 19.981083 TV_2 67.795773 TV_3 20.366270 TV_4 38.130762 TV_5 -86.733684 TV_6 -62.747017 TV_7 57.276712 TV_8 -73.160058 TV_9 -137.411201 TV_competitor_1 5.744274 TV_competitor_2 -55.923583 TV_competitor_3 27.666143 TV_competitor_4 116.277123 Press 7.251206 dtype: float64
ac.summary()
| Dep. Variable: | Sales | R-squared: | 0.505 |
|---|---|---|---|
| Model: | OLS | Adj. R-squared: | 0.441 |
| Method: | Least Squares | F-statistic: | 7.794 |
| Date: | Wed, 08 Sep 2021 | Prob (F-statistic): | 2.03e-12 |
| Time: | 09:03:42 | Log-Likelihood: | -1211.9 |
| No. Observations: | 139 | AIC: | 2458. |
| Df Residuals: | 122 | BIC: | 2508. |
| Df Model: | 16 | ||
| Covariance Type: | nonrobust |
| coef | std err | t | P>|t| | [0.025 | 0.975] | |
|---|---|---|---|---|---|---|
| Intercept | 2271.7157 | 1600.751 | 1.419 | 0.158 | -897.130 | 5440.561 |
| Brand_price | 14.3943 | 36.130 | 0.398 | 0.691 | -57.129 | 85.918 |
| Average_category_price | 46.5491 | 30.305 | 1.536 | 0.127 | -13.443 | 106.542 |
| TV_1 | 19.9811 | 7.922 | 2.522 | 0.013 | 4.299 | 35.663 |
| TV_2 | 67.7958 | 46.223 | 1.467 | 0.145 | -23.707 | 159.298 |
| TV_3 | 20.3663 | 22.467 | 0.906 | 0.366 | -24.110 | 64.842 |
| TV_4 | 38.1308 | 8.423 | 4.527 | 0.000 | 21.456 | 54.805 |
| TV_5 | -86.7337 | 128.089 | -0.677 | 0.500 | -340.299 | 166.831 |
| TV_6 | -62.7470 | 193.136 | -0.325 | 0.746 | -445.078 | 319.584 |
| TV_7 | 57.2767 | 114.434 | 0.501 | 0.618 | -169.257 | 283.810 |
| TV_8 | -73.1601 | 96.965 | -0.755 | 0.452 | -265.111 | 118.791 |
| TV_9 | -137.4112 | 100.424 | -1.368 | 0.174 | -336.211 | 61.389 |
| TV_competitor_1 | 5.7443 | 10.950 | 0.525 | 0.601 | -15.932 | 27.421 |
| TV_competitor_2 | -55.9236 | 39.815 | -1.405 | 0.163 | -134.742 | 22.895 |
| TV_competitor_3 | 27.6661 | 18.034 | 1.534 | 0.128 | -8.034 | 63.366 |
| TV_competitor_4 | 116.2771 | 25.792 | 4.508 | 0.000 | 65.220 | 167.334 |
| Press | 7.2512 | 7.391 | 0.981 | 0.328 | -7.380 | 21.883 |
| Omnibus: | 17.106 | Durbin-Watson: | 0.827 |
|---|---|---|---|
| Prob(Omnibus): | 0.000 | Jarque-Bera (JB): | 21.613 |
| Skew: | 0.729 | Prob(JB): | 2.03e-05 |
| Kurtosis: | 4.267 | Cond. No. | 1.75e+03 |
from scipy.optimize import minimize, Bounds, LinearConstraint, curve_fit
import pysolnp
def opt_rev_plot(revenue_table):
fig = go.Figure()
fig.add_trace(go.Scatter(
x=revenue_table['budget'].values,
y=(revenue_table['profit'].values),
name='optimal curve'
))
fig.update_layout(title='Optimal ROAS curve',
xaxis_title='Yearly investments (mln rub)',
yaxis_title='Expected yearly ROAS in comparison')
fig.show()
def neg_exponential_form(grp, beta, gamma, alpha=0, c=0):
return alpha + gamma*(1 - np.exp(-(beta*grp)))
def exp_just_draw_v2(revenue_table, params_table, product_price=1, period=12, budg=2*10**9, grad=10**6, means=dict(), media_costs=dict()):
opt_rev_dict = {}
revenue_coefficients = pd.DataFrame(columns=['media', 'beta', 'gamma'])
channels = [x for x in revenue_table.drop(
columns='Investment').columns if x[-5:] != '_ROAS']
for channel in channels:
print(channel)
delt = media_costs[media_costs['media'] == channel]['cost'].values[0]
revenue_table[channel] = revenue_table[channel]*product_price
grp = np.array(revenue_table['Investment'].values)
ydata = np.array(revenue_table[channel].values)
beta_start = float(params_table[params_table['feach_name']+params_table['coef_name'] == (
channel+'__diminish_beta')]['value'].values[0])
gamma_start = float(params_table[params_table['feach_name']+params_table['coef_name'] == (channel+'__diminish_gamma')]['value'].values[0])*float(
params_table[params_table['feach_name']+params_table['coef_name'] == (channel+'__lm_coef')]['value'].values[0])
if gamma_start < 0:
gamma_start = -1*gamma_start
for i in range(-5, 5, 1):
scale = 10**(i)
p0 = (beta_start/(scale*delt), gamma_start)
popt, pcov = curve_fit(neg_exponential_form, grp, ydata, p0=p0, method='trf', bounds=(
[0.000000000001, 0.0000000000001], [10000000, 100000000]), maxfev=10000000)
resp = neg_exponential_form(
np.array(range(0, budg, gran)), popt[0], popt[1], alpha=0, c=0)
error = abs(sum(resp)-sum(ydata))/sum(ydata)
if (error < 10**(-10)):
break
revenue_coefficients = revenue_coefficients.append(
{'media': channel, 'beta': popt[0], 'gamma': popt[1]}, ignore_index=True)
return revenue_coefficients
def optimal_budget_plot(optimised_budget):
# x axis
x = optimised_budget['budget']
fig = go.Figure()
media_cols = list(optimised_budget.drop(columns=['budget', 'profit']))
# plot first media variable
fig.add_trace(go.Scatter(
x=x,
y=optimised_budget[media_cols[0]],
mode='lines',
line=dict(width=0.5),
name=media_cols[0],
stackgroup='one',
groupnorm='percent'
))
# plot rest of media variables
for col in media_cols[1:]:
fig.add_trace(go.Scatter(
x=x,
y=optimised_budget[col],
mode='lines',
line=dict(width=0.5),
name=col,
stackgroup='one'
))
# set axis and labes
fig.update_layout(
title='Optimal Budget Split',
xaxis_title='Budget',
yaxis_title='Budget Split Percentage',
showlegend=True,
xaxis=dict(
tickmode='auto',
nticks=10,
ticksuffix=' Rub.'),
yaxis=dict(
type='linear',
range=[1, 100],
ticksuffix='%')
)
fig.show()
def resp_poly(revenue_table, col):
xp = list(revenue_table['Investment'].values)
fp = list(revenue_table[col].values)
# fp = [np.exp(-1/(x+10**4)) for x in fp]
min_a1_x, max_a1_x = min(xp), max(xp)
new_a1_x = list(revenue_table['Investment'].values)
a1_coefs = np.polyfit(xp, fp, 20)
return(np.poly1d(a1_coefs))
def get_param_name(name, params):
if '__lm_coef' in name:
return('__lm_coef')
if '__diminish_beta' in name:
return('__diminish_beta')
if '__diminish_gamma' in name:
return('__diminish_gamma')
if '__lambda_ad' in name:
return('__lambda_ad')
def get_params_table(params):
params_data = pd.DataFrame(
columns=['feach_name', 'coef_name', 'value', 'min_val', 'max_val', 'vary'])
for col in params.keys():
coef_name = get_param_name(params[col].name, params)
feach_name = params[col].name.replace(coef_name, '')
value = params[col].value
min_val = params[col].min
max_val = params[col].max
vary = params[col].vary
line = [feach_name, coef_name, value, min_val, max_val, vary]
row = pd.Series(line, ['feach_name', 'coef_name',
'value', 'min_val', 'max_val', 'vary'])
params_data = params_data.append([row])
return(params_data)
# Import dataset with sales and media
dataset = dataset=pd.read_csv('Media_data.csv', sep = ';').dropna()
# Import dataset with media costs data
media_costs=pd.DataFrame(columns=['media', 'cost', 'comment'])
media_costs['media']=['TV_1','TV_2','TV_3','TV_4','TV_5','TV_6','TV_7','TV_8','TV_9']
media_costs['cost']=[1,1,1,1,1,1,1,1,1]
dep_var=['Sales']
ad_vars=['TV_1','TV_2','TV_3','TV_4','TV_5','TV_6','TV_7','TV_8','TV_9', 'TV_competitor_1', 'TV_competitor_2', 'TV_competitor_3', 'TV_competitor_4']
market_vars=['baseline','Brand_price','Average_category_price','Press']
extra_vars = []
date='Week'
# dataset['Sales']=dataset['Sales']/1000
# dataset['TV_1']=dataset['TV_1']/100
# dataset['TV_2']=dataset['TV_2']/100
# dataset['TV_3']=dataset['TV_3']/100
# dataset['TV_4']=dataset['TV_4']/100
# dataset['TV_5']=dataset['TV_5']/100
# dataset['TV_6']=dataset['TV_6']/100
# dataset['TV_7']=dataset['TV_7']/100
# dataset['TV_8']=dataset['TV_8']/100
# dataset['TV_9']=dataset['TV_9']/100
# dataset['TV_competitor_1']=dataset['TV_competitor_1']/100
# dataset['TV_competitor_2']=dataset['TV_competitor_2']/100
# dataset['TV_competitor_3']=dataset['TV_competitor_3']/100
# dataset['TV_competitor_4']=dataset['TV_competitor_4']/100
# dataset['Press']=dataset['Press']/100
# dataset['Brand_price']=dataset['Brand_price']/100
# dataset['Average_category_price ']=dataset['Average_category_price']/100
X_train=mmm_pyton.MMM_dataset(dataset, dep_var, ad_vars, market_vars, extra_vars, date)
X_train_1=mmm_pyton.MMM_dataset(dataset, dep_var, ad_vars, market_vars, extra_vars, date)
y_train=X_train[dep_var[0]]
X_train=X_train.drop(columns=[dep_var[0]])
cols2impute = X_train.columns[(X_train.isnull().any() == True)]
cols2impute.values.tolist()
cols2diminish = X_train.columns[X_train.columns.str.contains('RF|TV|IMP')]
cols2diminish.values.tolist()
['baseline'] ['baseline']
['TV_1', 'TV_2', 'TV_3', 'TV_4', 'TV_5', 'TV_6', 'TV_7', 'TV_8', 'TV_9', 'TV_competitor_1', 'TV_competitor_2', 'TV_competitor_3', 'TV_competitor_4']
# Scaling
means = {}
means[dep_var[0]] = y_train.mean()
y_train = y_train/y_train.mean()
for col in ad_vars:
means[col] = X_train[col].mean()
X_train[col] = X_train[col]/X_train[col].mean()
for col in [x for x in market_vars if x not in ['seasonality', 'weekend']]:
means[col] = X_train[col].mean()
X_train[col] = X_train[col]/X_train[col].mean()
if 'seasonality' in market_vars:
means['seasonality'] = X_train['seasonality'].std()
X_train['seasonality'] = X_train['seasonality'] / \
X_train['seasonality'].std()
# Parameter space
params = Parameters()
for col in ad_vars:
params.add(
name=col + '__lambda_ad',
value=0.3,
min=0.1,
max=0.6,
# vary=False
)
for col in ad_vars:
params.add(
name = col + '__diminish_beta',
value = 0.00055,
min=0.00001,
max=0.1,
# vary=False
)
for col in ad_vars:
params.add(
name=col + '__diminish_gamma',
value=1,
min=0.0001,
max=10,
vary=False
)
for col in ad_vars:
if 'competitor' in col:
params.add(
name=col + '__lm_coef',
value=1,
min=-1000,
max=-0.0000001,
vary=True
)
else:
params.add(
name=col + '__lm_coef',
value=1,
min=0.0000001,
max=1000,
vary=True
)
for col in market_vars:
params.add(
name=col + '__lm_coef',
value=1,
min=-1000,
max=1000,
vary=True
)
params
| name | value | initial value | min | max | vary |
|---|---|---|---|---|---|
| TV_1__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_2__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_3__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_4__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_5__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_6__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_7__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_8__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_9__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_1__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_2__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_3__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_4__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_1__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_2__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_3__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_4__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_5__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_6__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_7__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_8__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_9__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_1__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_2__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_3__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_4__diminish_beta | 5.5000e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_1__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_2__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_3__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_4__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_5__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_6__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_7__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_8__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_9__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_1__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_2__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_3__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_4__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_1__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_2__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_3__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_4__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_5__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_6__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_7__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_8__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_9__lm_coef | 1.00000000 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_competitor_1__lm_coef | -1.0000e-07 | 1 | -1000.00000 | -1.0000e-07 | True |
| TV_competitor_2__lm_coef | -1.0000e-07 | 1 | -1000.00000 | -1.0000e-07 | True |
| TV_competitor_3__lm_coef | -1.0000e-07 | 1 | -1000.00000 | -1.0000e-07 | True |
| TV_competitor_4__lm_coef | -1.0000e-07 | 1 | -1000.00000 | -1.0000e-07 | True |
| baseline__lm_coef | 1.00000000 | 1 | -1000.00000 | 1000.00000 | True |
| Brand_price__lm_coef | 1.00000000 | 1 | -1000.00000 | 1000.00000 | True |
| Average_category_price__lm_coef | 1.00000000 | 1 | -1000.00000 | 1000.00000 | True |
| Press__lm_coef | 1.00000000 | 1 | -1000.00000 | 1000.00000 | True |
result=mmm_pyton.model(params,cols2impute,cols2diminish,X_train,y_train,maxiter=150)
| niter |f evals|CG iter| obj func |tr radius | opt | c viol | penalty |CG stop| |-------|-------|-------|-------------|----------|----------|----------|----------|-------| | 1 | 44 | 0 | +1.5653e+03 | 1.00e+00 | 1.45e+06 | 0.00e+00 | 1.00e+00 | 0 | | 2 | 88 | 1 | +1.5653e+03 | 1.00e-01 | 1.45e+06 | 0.00e+00 | 1.00e+00 | 2 | | 3 | 132 | 3 | +1.3776e+02 | 1.00e-01 | 4.89e+05 | 0.00e+00 | 1.00e+00 | 4 | | 4 | 176 | 5 | +1.8785e+01 | 1.00e-01 | 9.04e+04 | 0.00e+00 | 1.00e+00 | 4 | | 5 | 220 | 7 | +6.9447e+00 | 1.00e-01 | 2.13e+04 | 0.00e+00 | 1.00e+00 | 4 | | 6 | 264 | 9 | +5.6551e+00 | 1.00e-01 | 1.83e+04 | 0.00e+00 | 1.00e+00 | 4 | | 7 | 308 | 11 | +5.0898e+00 | 1.00e-01 | 3.08e+03 | 0.00e+00 | 1.00e+00 | 4 | | 8 | 352 | 14 | +5.0843e+00 | 1.00e-01 | 5.63e+02 | 0.00e+00 | 1.00e+00 | 4 | | 9 | 396 | 17 | +5.0838e+00 | 1.00e-01 | 5.01e+02 | 0.00e+00 | 1.00e+00 | 4 | | 10 | 440 | 20 | +5.0826e+00 | 1.00e-01 | 8.21e+02 | 0.00e+00 | 1.00e+00 | 4 | | 11 | 484 | 23 | +5.0795e+00 | 1.00e-01 | 1.81e+03 | 0.00e+00 | 1.00e+00 | 4 | | 12 | 528 | 27 | +5.0724e+00 | 1.00e-01 | 3.19e+03 | 0.00e+00 | 1.00e+00 | 4 | | 13 | 572 | 31 | +5.0582e+00 | 1.00e-01 | 4.52e+03 | 0.00e+00 | 1.00e+00 | 4 | | 14 | 616 | 35 | +5.0385e+00 | 1.00e-01 | 4.57e+03 | 0.00e+00 | 1.00e+00 | 4 | | 15 | 660 | 39 | +5.0244e+00 | 1.00e-01 | 2.57e+03 | 0.00e+00 | 1.00e+00 | 4 | | 16 | 704 | 43 | +5.0203e+00 | 1.00e-01 | 5.88e+02 | 0.00e+00 | 1.00e+00 | 4 | | 17 | 748 | 47 | +5.0199e+00 | 1.00e-01 | 2.11e+02 | 0.00e+00 | 1.00e+00 | 4 | | 18 | 792 | 52 | +5.0198e+00 | 1.00e-01 | 2.56e+02 | 0.00e+00 | 1.00e+00 | 4 | | 19 | 836 | 57 | +5.0196e+00 | 1.00e-01 | 3.28e+02 | 0.00e+00 | 1.00e+00 | 4 | | 20 | 880 | 62 | +5.0190e+00 | 1.00e-01 | 4.63e+02 | 0.00e+00 | 1.00e+00 | 4 | | 21 | 924 | 67 | +5.0173e+00 | 1.00e-01 | 8.08e+02 | 0.00e+00 | 1.00e+00 | 4 | | 22 | 968 | 72 | +5.0133e+00 | 1.00e-01 | 1.32e+03 | 0.00e+00 | 1.00e+00 | 4 | | 23 | 1012 | 77 | +5.0037e+00 | 1.00e-01 | 2.03e+03 | 0.00e+00 | 1.00e+00 | 4 | | 24 | 1056 | 82 | +4.9841e+00 | 1.00e-01 | 2.72e+03 | 0.00e+00 | 1.00e+00 | 4 | | 25 | 1100 | 87 | +4.9552e+00 | 1.00e-01 | 2.74e+03 | 0.00e+00 | 1.00e+00 | 4 | | 26 | 1144 | 92 | +4.9323e+00 | 1.00e-01 | 1.60e+03 | 0.00e+00 | 1.00e+00 | 4 | | 27 | 1188 | 97 | +4.9247e+00 | 1.00e-01 | 3.70e+02 | 0.00e+00 | 1.00e+00 | 4 | | 28 | 1232 | 102 | +4.9240e+00 | 1.00e-01 | 2.53e+01 | 0.00e+00 | 1.00e+00 | 4 | | 29 | 1276 | 107 | +4.9240e+00 | 1.00e-01 | 3.22e+00 | 0.00e+00 | 1.00e+00 | 4 | | 30 | 1320 | 113 | +4.9240e+00 | 1.00e-02 | 3.22e+00 | 0.00e+00 | 1.00e+00 | 4 | | 31 | 1364 | 119 | +4.9240e+00 | 1.00e-03 | 3.22e+00 | 0.00e+00 | 1.00e+00 | 4 | | 32 | 1408 | 125 | +4.9240e+00 | 1.00e-04 | 3.22e+00 | 0.00e+00 | 1.00e+00 | 4 | | 33 | 1452 | 131 | +4.9240e+00 | 1.00e-05 | 3.22e+00 | 0.00e+00 | 1.00e+00 | 4 | | 34 | 1496 | 137 | +4.9240e+00 | 1.71e-06 | 3.22e+00 | 0.00e+00 | 1.00e+00 | 4 | | 35 | 1540 | 139 | +4.9240e+00 | 1.71e-06 | 2.32e+01 | 0.00e+00 | 1.00e+00 | 2 | | 36 | 1584 | 143 | +4.9240e+00 | 3.42e-06 | 1.39e+01 | 0.00e+00 | 1.00e+00 | 2 | | 37 | 1628 | 148 | +4.9240e+00 | 2.40e-05 | 1.07e+01 | 0.00e+00 | 1.00e+00 | 2 | | 38 | 1672 | 154 | +4.9240e+00 | 1.68e-04 | 4.02e+01 | 0.00e+00 | 1.00e+00 | 2 | | 39 | 1716 | 160 | +4.9238e+00 | 1.17e-03 | 1.78e+02 | 0.00e+00 | 1.00e+00 | 2 | | 40 | 1760 | 165 | +4.9238e+00 | 1.17e-03 | 1.29e+02 | 0.00e+00 | 1.00e+00 | 4 | | 41 | 1804 | 173 | +4.9228e+00 | 3.94e-03 | 2.36e+01 | 0.00e+00 | 1.00e+00 | 4 | | 42 | 1848 | 181 | +4.9172e+00 | 2.76e-02 | 4.50e+02 | 0.00e+00 | 1.00e+00 | 2 | | 43 | 1892 | 189 | +4.9168e+00 | 2.76e-02 | 3.04e+02 | 0.00e+00 | 1.00e+00 | 4 | | 44 | 1936 | 197 | +4.9164e+00 | 2.76e-02 | 3.72e+00 | 0.00e+00 | 1.00e+00 | 4 | | 45 | 1980 | 206 | +4.8756e+00 | 1.93e-01 | 3.07e+02 | 0.00e+00 | 1.00e+00 | 2 | | 46 | 2024 | 214 | +4.8750e+00 | 1.93e-01 | 6.93e+01 | 0.00e+00 | 1.00e+00 | 4 | | 47 | 2068 | 223 | +4.5933e+00 | 1.35e+00 | 2.42e+03 | 0.00e+00 | 1.00e+00 | 2 | | 48 | 2112 | 231 | +4.5795e+00 | 1.35e+00 | 1.92e+02 | 0.00e+00 | 1.00e+00 | 4 | | 49 | 2156 | 241 | +3.8350e+00 | 2.09e+00 | 5.88e+03 | 0.00e+00 | 1.00e+00 | 4 | | 50 | 2200 | 249 | +3.7796e+00 | 2.09e+00 | 2.48e+03 | 0.00e+00 | 1.00e+00 | 4 | | 51 | 2244 | 257 | +3.7674e+00 | 2.09e+00 | 1.07e+01 | 0.00e+00 | 1.00e+00 | 4 | | 52 | 2288 | 267 | +3.7674e+00 | 2.09e-01 | 1.07e+01 | 0.00e+00 | 1.00e+00 | 4 | | 53 | 2332 | 277 | +3.7673e+00 | 2.09e-01 | 4.55e+01 | 0.00e+00 | 1.00e+00 | 4 | | 54 | 2376 | 287 | +3.7672e+00 | 2.09e-01 | 4.57e+01 | 0.00e+00 | 1.00e+00 | 4 | | 55 | 2420 | 298 | +3.7381e+00 | 2.09e-01 | 2.60e+03 | 0.00e+00 | 1.00e+00 | 4 | | 56 | 2464 | 304 | +3.7250e+00 | 2.09e-01 | 9.90e+01 | 0.00e+00 | 1.00e+00 | 4 | | 57 | 2508 | 315 | +3.6540e+00 | 2.09e-01 | 9.04e+02 | 0.00e+00 | 1.00e+00 | 4 | | 58 | 2552 | 321 | +3.6524e+00 | 2.09e-01 | 8.33e+00 | 0.00e+00 | 1.00e+00 | 4 | | 59 | 2596 | 332 | +3.6456e+00 | 2.09e-01 | 2.94e+01 | 0.00e+00 | 1.00e+00 | 4 | | 60 | 2640 | 335 | +3.6455e+00 | 2.09e-01 | 1.86e+00 | 0.00e+00 | 1.00e+00 | 4 | | 61 | 2684 | 346 | +3.6451e+00 | 2.09e-01 | 1.08e+01 | 0.00e+00 | 1.00e+00 | 4 | | 62 | 2728 | 352 | +3.6451e+00 | 2.09e-01 | 1.84e+00 | 0.00e+00 | 1.00e+00 | 4 | | 63 | 2772 | 354 | +3.6451e+00 | 2.09e-01 | 1.84e+00 | 0.00e+00 | 1.00e+00 | 4 | | 64 | 2816 | 358 | +3.6451e+00 | 2.09e-01 | 9.87e+00 | 0.00e+00 | 1.00e+00 | 4 | | 65 | 2860 | 363 | +3.6451e+00 | 2.09e-01 | 2.02e+01 | 0.00e+00 | 1.00e+00 | 4 | | 66 | 2904 | 368 | +3.6451e+00 | 2.09e-01 | 4.00e+01 | 0.00e+00 | 1.00e+00 | 4 | | 67 | 2948 | 373 | +3.6451e+00 | 2.09e-01 | 7.01e+01 | 0.00e+00 | 1.00e+00 | 4 | | 68 | 2992 | 379 | +3.6451e+00 | 2.09e-01 | 1.20e+02 | 0.00e+00 | 1.00e+00 | 4 | | 69 | 3036 | 385 | +3.6451e+00 | 2.09e-01 | 2.00e+02 | 0.00e+00 | 1.00e+00 | 4 | | 70 | 3080 | 391 | +3.6451e+00 | 2.09e-01 | 3.30e+02 | 0.00e+00 | 1.00e+00 | 4 | | 71 | 3124 | 394 | +3.6451e+00 | 2.09e-01 | 2.64e+02 | 0.00e+00 | 1.00e+00 | 4 | | 72 | 3168 | 402 | +3.6446e+00 | 2.09e-01 | 4.41e+00 | 0.00e+00 | 1.00e+00 | 4 | | 73 | 3212 | 412 | +3.6412e+00 | 2.09e-01 | 1.27e+03 | 0.00e+00 | 1.00e+00 | 4 | | 74 | 3256 | 415 | +3.6406e+00 | 2.09e-01 | 8.02e+02 | 0.00e+00 | 1.00e+00 | 4 | | 75 | 3300 | 425 | +3.6259e+00 | 2.09e-01 | 2.69e+01 | 0.00e+00 | 1.00e+00 | 4 | | 76 | 3344 | 441 | +3.5445e+00 | 2.09e-01 | 4.90e+03 | 0.00e+00 | 1.00e+00 | 4 | | 77 | 3388 | 449 | +3.5173e+00 | 2.09e-01 | 2.03e+03 | 0.00e+00 | 1.00e+00 | 4 | | 78 | 3432 | 457 | +3.5145e+00 | 2.09e-01 | 3.51e+02 | 0.00e+00 | 1.00e+00 | 4 | | 79 | 3476 | 468 | +3.4966e+00 | 2.09e-01 | 1.10e+02 | 0.00e+00 | 1.00e+00 | 4 | | 80 | 3520 | 479 | +3.4869e+00 | 2.09e-01 | 1.19e+02 | 0.00e+00 | 1.00e+00 | 4 | | 81 | 3564 | 485 | +3.4869e+00 | 2.09e-01 | 2.03e+01 | 0.00e+00 | 1.00e+00 | 4 | | 82 | 3608 | 493 | +3.4869e+00 | 2.09e-02 | 2.03e+01 | 0.00e+00 | 1.00e+00 | 4 | | 83 | 3652 | 501 | +3.4869e+00 | 2.09e-03 | 2.03e+01 | 0.00e+00 | 1.00e+00 | 4 | | 84 | 3696 | 510 | +3.4869e+00 | 2.09e-04 | 2.03e+01 | 0.00e+00 | 1.00e+00 | 4 | | 85 | 3740 | 519 | +3.4869e+00 | 2.09e-05 | 2.03e+01 | 0.00e+00 | 1.00e+00 | 4 | | 86 | 3784 | 527 | +3.4869e+00 | 2.09e-05 | 1.03e+01 | 0.00e+00 | 1.00e+00 | 4 | | 87 | 3828 | 534 | +3.4869e+00 | 1.46e-04 | 2.02e+01 | 0.00e+00 | 1.00e+00 | 2 | | 88 | 3872 | 544 | +3.4868e+00 | 4.10e-04 | 3.71e+01 | 0.00e+00 | 1.00e+00 | 4 | | 89 | 3916 | 554 | +3.4867e+00 | 1.19e-03 | 6.61e+01 | 0.00e+00 | 1.00e+00 | 4 | | 90 | 3960 | 564 | +3.4864e+00 | 3.14e-03 | 1.11e+02 | 0.00e+00 | 1.00e+00 | 4 | | 91 | 4004 | 570 | +3.4862e+00 | 3.14e-03 | 8.76e+01 | 0.00e+00 | 1.00e+00 | 4 | | 92 | 4048 | 580 | +3.4829e+00 | 1.42e-02 | 2.71e+00 | 0.00e+00 | 1.00e+00 | 4 | | 93 | 4092 | 592 | +3.4698e+00 | 9.93e-02 | 2.53e+02 | 0.00e+00 | 1.00e+00 | 2 | | 94 | 4136 | 600 | +3.4686e+00 | 9.93e-02 | 9.91e+01 | 0.00e+00 | 1.00e+00 | 4 | | 95 | 4180 | 606 | +3.4683e+00 | 9.93e-02 | 5.87e-01 | 0.00e+00 | 1.00e+00 | 4 | | 96 | 4224 | 622 | +3.4555e+00 | 1.69e-01 | 7.28e+01 | 0.00e+00 | 1.00e+00 | 4 | | 97 | 4268 | 628 | +3.4555e+00 | 1.69e-01 | 5.80e-01 | 0.00e+00 | 1.00e+00 | 4 | | 98 | 4312 | 651 | +3.4488e+00 | 1.95e-01 | 7.88e+01 | 0.00e+00 | 1.00e+00 | 4 | | 99 | 4356 | 657 | +3.4488e+00 | 1.95e-01 | 5.60e-01 | 0.00e+00 | 1.00e+00 | 4 | | 100 | 4400 | 668 | +3.4481e+00 | 1.95e-01 | 8.97e+00 | 0.00e+00 | 1.00e+00 | 4 | | 101 | 4444 | 671 | +3.4481e+00 | 1.95e-01 | 6.30e-01 | 0.00e+00 | 1.00e+00 | 4 | | 102 | 4488 | 682 | +3.4480e+00 | 1.95e-01 | 9.18e+00 | 0.00e+00 | 1.00e+00 | 4 | | 103 | 4532 | 688 | +3.4480e+00 | 1.95e-02 | 9.18e+00 | 0.00e+00 | 1.00e+00 | 4 | | 104 | 4576 | 694 | +3.4480e+00 | 1.95e-03 | 9.18e+00 | 0.00e+00 | 1.00e+00 | 4 | | 105 | 4620 | 701 | +3.4480e+00 | 1.95e-04 | 9.18e+00 | 0.00e+00 | 1.00e+00 | 4 | | 106 | 4664 | 707 | +3.4480e+00 | 1.95e-04 | 1.85e+01 | 0.00e+00 | 1.00e+00 | 4 | | 107 | 4708 | 715 | +3.4480e+00 | 1.95e-04 | 4.46e+01 | 0.00e+00 | 1.00e+00 | 4 | | 108 | 4752 | 720 | +3.4480e+00 | 1.95e-04 | 3.55e+01 | 0.00e+00 | 1.00e+00 | 4 | | 109 | 4796 | 728 | +3.4480e+00 | 1.95e-04 | 1.59e+01 | 0.00e+00 | 1.00e+00 | 4 | | 110 | 4840 | 735 | +3.4479e+00 | 1.37e-03 | 6.30e+01 | 0.00e+00 | 1.00e+00 | 2 | | 111 | 4884 | 743 | +3.4479e+00 | 1.37e-03 | 5.13e+01 | 0.00e+00 | 1.00e+00 | 4 | | 112 | 4928 | 754 | +3.4474e+00 | 4.89e-03 | 1.57e+02 | 0.00e+00 | 1.00e+00 | 4 | | 113 | 4972 | 759 | +3.4473e+00 | 4.89e-03 | 7.94e+01 | 0.00e+00 | 1.00e+00 | 4 | | 114 | 5016 | 767 | +3.4473e+00 | 4.89e-03 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 115 | 5060 | 778 | +3.4443e+00 | 3.00e-02 | 9.92e+01 | 0.00e+00 | 1.00e+00 | 4 | | 116 | 5104 | 786 | +3.4442e+00 | 3.00e-02 | 3.02e+01 | 0.00e+00 | 1.00e+00 | 4 | | 117 | 5148 | 797 | +3.4367e+00 | 1.27e-01 | 1.15e+02 | 0.00e+00 | 1.00e+00 | 4 | | 118 | 5192 | 805 | +3.4367e+00 | 1.27e-01 | 3.51e-01 | 0.00e+00 | 1.00e+00 | 4 | | 119 | 5236 | 836 | +3.4334e+00 | 1.48e-01 | 6.25e+01 | 0.00e+00 | 1.00e+00 | 4 | | 120 | 5280 | 839 | +3.4334e+00 | 1.48e-01 | 4.28e-01 | 0.00e+00 | 1.00e+00 | 4 | | 121 | 5324 | 855 | +3.4331e+00 | 1.48e-01 | 1.90e+01 | 0.00e+00 | 1.00e+00 | 4 | | 122 | 5368 | 860 | +3.4331e+00 | 1.48e-01 | 2.75e-01 | 0.00e+00 | 1.00e+00 | 4 | | 123 | 5412 | 872 | +3.4330e+00 | 1.48e-01 | 1.69e+00 | 0.00e+00 | 1.00e+00 | 4 | | 124 | 5456 | 875 | +3.4330e+00 | 1.48e-01 | 2.56e-01 | 0.00e+00 | 1.00e+00 | 4 | | 125 | 5500 | 887 | +3.4330e+00 | 1.48e-01 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 126 | 5544 | 889 | +3.4330e+00 | 1.48e-02 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 127 | 5588 | 891 | +3.4330e+00 | 1.48e-03 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 128 | 5632 | 894 | +3.4330e+00 | 1.48e-04 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 129 | 5676 | 899 | +3.4330e+00 | 1.48e-05 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 130 | 5720 | 904 | +3.4330e+00 | 1.48e-06 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 4 | | 131 | 5764 | 909 | +3.4330e+00 | 7.38e-07 | 1.39e+00 | 0.00e+00 | 1.00e+00 | 2 | | 132 | 5808 | 912 | +3.4330e+00 | 1.48e-06 | 7.35e+00 | 0.00e+00 | 1.00e+00 | 2 | | 133 | 5852 | 917 | +3.4330e+00 | 1.03e-05 | 1.17e+01 | 0.00e+00 | 1.00e+00 | 2 | | 134 | 5896 | 925 | +3.4330e+00 | 7.23e-05 | 5.06e+01 | 0.00e+00 | 1.00e+00 | 2 | | 135 | 5940 | 928 | +3.4330e+00 | 7.23e-05 | 3.38e+01 | 0.00e+00 | 1.00e+00 | 4 | | 136 | 5984 | 932 | +3.4330e+00 | 7.23e-05 | 3.45e-01 | 0.00e+00 | 1.00e+00 | 4 | | 137 | 6028 | 944 | +3.4330e+00 | 3.11e-04 | 1.92e+01 | 0.00e+00 | 1.00e+00 | 4 | | 138 | 6072 | 955 | +3.4328e+00 | 2.18e-03 | 8.21e+01 | 0.00e+00 | 1.00e+00 | 2 | | 139 | 6116 | 959 | +3.4328e+00 | 2.18e-03 | 5.25e+01 | 0.00e+00 | 1.00e+00 | 4 | | 140 | 6160 | 970 | +3.4328e+00 | 2.18e-04 | 5.25e+01 | 0.00e+00 | 1.00e+00 | 4 | | 141 | 6204 | 981 | +3.4328e+00 | 2.18e-05 | 5.25e+01 | 0.00e+00 | 1.00e+00 | 4 | | 142 | 6248 | 992 | +3.4328e+00 | 4.51e-06 | 5.25e+01 | 0.00e+00 | 1.00e+00 | 4 | | 143 | 6292 | 1002 | +3.4328e+00 | 2.26e-06 | 5.25e+01 | 0.00e+00 | 1.00e+00 | 4 | | 144 | 6336 | 1012 | +3.4328e+00 | 4.51e-06 | 6.58e+00 | 0.00e+00 | 1.00e+00 | 2 | | 145 | 6380 | 1022 | +3.4328e+00 | 1.87e-06 | 6.58e+00 | 0.00e+00 | 1.00e+00 | 2 | | 146 | 6424 | 1032 | +3.4328e+00 | 7.77e-07 | 6.58e+00 | 0.00e+00 | 1.00e+00 | 2 | | 147 | 6468 | 1042 | +3.4328e+00 | 2.40e-07 | 6.58e+00 | 0.00e+00 | 1.00e+00 | 2 | | 148 | 6512 | 1048 | +3.4328e+00 | 9.25e-08 | 6.58e+00 | 0.00e+00 | 1.00e+00 | 2 | | 149 | 6556 | 1054 | +3.4328e+00 | 4.62e-08 | 6.58e+00 | 0.00e+00 | 1.00e+00 | 2 | | 150 | 6600 | 1059 | +3.4328e+00 | 9.25e-08 | 2.46e+00 | 0.00e+00 | 1.00e+00 | 2 | The maximum number of function evaluations is exceeded. Number of iterations: 150, function evaluations: 6600, CG iterations: 1059, optimality: 2.46e+00, constraint violation: 0.00e+00, execution time: 2e+02 s.
result
| fitting method | equality_constrained_sqp | |
| # function evals | 6600 | |
| # data points | 139 | |
| # variables | 43 | |
| chi-square | 3.43279935 | |
| reduced chi-square | 0.03575833 | |
| Akaike info crit. | -428.452604 | |
| Bayesian info crit. | -302.270225 |
| name | value | initial value | min | max | vary |
|---|---|---|---|---|---|
| TV_1__lambda_ad | 0.30303699 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_2__lambda_ad | 0.30089219 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_3__lambda_ad | 0.29986129 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_4__lambda_ad | 0.30425889 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_5__lambda_ad | 0.29971337 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_6__lambda_ad | 0.29990602 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_7__lambda_ad | 0.29964113 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_8__lambda_ad | 0.30019051 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_9__lambda_ad | 0.29972196 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_1__lambda_ad | 0.29999940 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_2__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_3__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_competitor_4__lambda_ad | 0.30000000 | 0.3 | 0.10000000 | 0.60000000 | True |
| TV_1__diminish_beta | 0.00209366 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_2__diminish_beta | 7.6947e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_3__diminish_beta | 6.7866e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_4__diminish_beta | 0.00163076 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_5__diminish_beta | 7.9730e-05 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_6__diminish_beta | 1.3213e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_7__diminish_beta | 4.5607e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_8__diminish_beta | 1.1493e-05 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_9__diminish_beta | 4.5981e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_1__diminish_beta | 5.4782e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_2__diminish_beta | 5.5200e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_3__diminish_beta | 5.5172e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_competitor_4__diminish_beta | 5.4562e-04 | 0.00055 | 1.0000e-05 | 0.10000000 | True |
| TV_1__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_2__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_3__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_4__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_5__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_6__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_7__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_8__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_9__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_1__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_2__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_3__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_competitor_4__diminish_gamma | 1.00000000 | 1 | 1.0000e-04 | 10.0000000 | False |
| TV_1__lm_coef | 22.1180701 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_2__lm_coef | 7.33799577 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_3__lm_coef | 3.82560201 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_4__lm_coef | 23.6269004 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_5__lm_coef | 0.65059427 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_6__lm_coef | 0.32506329 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_7__lm_coef | 0.24837866 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_8__lm_coef | 19.0971454 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_9__lm_coef | 0.17235058 | 1 | 1.0000e-07 | 1000.00000 | True |
| TV_competitor_1__lm_coef | -4.7665e-05 | -1e-07 | -1000.00000 | -1.0000e-07 | True |
| TV_competitor_2__lm_coef | -2.5112e-04 | -1e-07 | -1000.00000 | -1.0000e-07 | True |
| TV_competitor_3__lm_coef | -1.3420e-05 | -1e-07 | -1000.00000 | -1.0000e-07 | True |
| TV_competitor_4__lm_coef | -4.7949e-06 | -1e-07 | -1000.00000 | -1.0000e-07 | True |
| baseline__lm_coef | 0.26657679 | 1 | -1000.00000 | 1000.00000 | True |
| Brand_price__lm_coef | -0.42784802 | 1 | -1000.00000 | 1000.00000 | True |
| Average_category_price__lm_coef | 1.04825171 | 1 | -1000.00000 | 1000.00000 | True |
| Press__lm_coef | 0.01988647 | 1 | -1000.00000 | 1000.00000 | True |
r2_score(y_train, mmm_pyton.get_prediction(result.params.valuesdict(), X_train, cols2impute, cols2diminish))
0.41779431116996746
# Estimate impact sizes with pretrained model
decomposition_df_sshape = mmm_pyton.model_dt(
result, X_train, y_train, cols2impute, ad_vars)
# Plot the decomposition
for col in decomposition_df_sshape.columns:
decomposition_df_sshape[col] = decomposition_df_sshape[col] * \
means[dep_var[0]]
params_sshape = result.params
mmm_pyton.decomposition(decomposition_df_sshape)
# Calculate metrics and statistics
r2_sshape = r2_score(
decomposition_df_sshape['actual'].values, decomposition_df_sshape['fitted'].values)
ad_r2_sshape = 1-(1-r2_sshape)*(len(y_train)-1) / \
(len(y_train)-X_train.shape[1]-1)
# pvalue_sshape_table=mmm_python.decomp_stat_calc(decomposition_df_sshape[clicks+['actual','fitted']])
# Print model metrices
print('R-squared: ' + str(np.round(r2_sshape*100, 1)) + '%')
print('Adjusted R-squared: ' + str(np.round(ad_r2_sshape*100, 1)) + '%')
# display(pvalue_sshape_table)
R-squared: 41.8% Adjusted R-squared: 33.6%
best_params=result.params.valuesdict()
means
{'Sales': 10217.510791366907,
'TV_1': 12.496402877697841,
'TV_2': 1.9640287769784173,
'TV_3': 2.035971223021583,
'TV_4': 7.705035971223022,
'TV_5': 0.5179856115107914,
'TV_6': 0.381294964028777,
'TV_7': 0.30935251798561153,
'TV_8': 0.2014388489208633,
'TV_9': 0.41007194244604317,
'TV_competitor_1': 5.517985611510792,
'TV_competitor_2': 2.0863309352517985,
'TV_competitor_3': 3.7697841726618706,
'TV_competitor_4': 3.697841726618705,
'baseline': 1.0,
'Brand_price': 72.4820143884892,
'Average_category_price': 123.67625899280576,
'Press': 13.827338129496402}
product_price=10217*123
budg=3*10**8
revenue_table=mmm_pyton.direct_response_curves(budg,best_params,media_costs,period=52)
# import importlib
# importlib.reload(mmm_pyton)
revenue_table=mmm_pyton.response_curves_plot(revenue_table)
mmm_pyton.ROAS_curves_plot(revenue_table, budg, product_price)
# Create params table
params_table = get_params_table(params)
params_table
| feach_name | coef_name | value | min_val | max_val | vary | |
|---|---|---|---|---|---|---|
| 0 | TV_1 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_2 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_3 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_4 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_5 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_6 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_7 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_8 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_9 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_competitor_1 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_competitor_2 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_competitor_3 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_competitor_4 | __lambda_ad | 3.000000e-01 | 1.000000e-01 | 6.000000e-01 | True |
| 0 | TV_1 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_2 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_3 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_4 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_5 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_6 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_7 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_8 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_9 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_competitor_1 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_competitor_2 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_competitor_3 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_competitor_4 | __diminish_beta | 5.500000e-04 | 1.000000e-05 | 1.000000e-01 | True |
| 0 | TV_1 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_2 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_3 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_4 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_5 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_6 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_7 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_8 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_9 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_competitor_1 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_competitor_2 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_competitor_3 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_competitor_4 | __diminish_gamma | 1.000000e+00 | 1.000000e-04 | 1.000000e+01 | False |
| 0 | TV_1 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_2 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_3 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_4 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_5 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_6 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_7 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_8 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_9 | __lm_coef | 1.000000e+00 | 1.000000e-07 | 1.000000e+03 | True |
| 0 | TV_competitor_1 | __lm_coef | -1.000000e-07 | -1.000000e+03 | -1.000000e-07 | True |
| 0 | TV_competitor_2 | __lm_coef | -1.000000e-07 | -1.000000e+03 | -1.000000e-07 | True |
| 0 | TV_competitor_3 | __lm_coef | -1.000000e-07 | -1.000000e+03 | -1.000000e-07 | True |
| 0 | TV_competitor_4 | __lm_coef | -1.000000e-07 | -1.000000e+03 | -1.000000e-07 | True |
| 0 | baseline | __lm_coef | 1.000000e+00 | -1.000000e+03 | 1.000000e+03 | True |
| 0 | Brand_price | __lm_coef | 1.000000e+00 | -1.000000e+03 | 1.000000e+03 | True |
| 0 | Average_category_price | __lm_coef | 1.000000e+00 | -1.000000e+03 | 1.000000e+03 | True |
| 0 | Press | __lm_coef | 1.000000e+00 | -1.000000e+03 | 1.000000e+03 | True |
gran = 1000000
model_type = 'exp'
revenue_coefficients = exp_just_draw_v2(revenue_table, params_table, product_price=1, period=12, budg=budg, grad=10**4, means=means, media_costs=media_costs)
# revenue_coefficients=exp_just_draw_v2(revenue_table_val, params_table, product_price=1, period=1, budg=budg_upd, grad=10**4, means=means, media_costs=media_costs)
media_vars = revenue_coefficients['media'].tolist()
resp_func_dict = {}
for col in media_vars:
resp_func_dict[col] = resp_poly(revenue_table, col)
# Bounds for x
bounds = Bounds(np.repeat(0, len(media_vars)), np.repeat(1, len(media_vars)))
# x start values
x0 = list(np.repeat(0.01/len(media_vars), len(media_vars)))
# Media vars columns
columns = revenue_coefficients['media'].tolist()
columns.insert(0, 'budget')
columns.insert(len(columns), 'profit')
# DF to fill out by optimization function
optimised_budget = pd.DataFrame(columns=columns)
# Row number of optimised_budget DF
row_n = 0
# Return DF with optimisation results
# for budggg in range(0, int(sum(sat_dict.values())/10**4)): # set maximum investments in millions
for budggg in range(1, 300): # set maximum investments in millions
print(budggg)
row = []
budget = budggg*(10**5)
row.append(budget)
x0 = list(np.repeat(0.01/len(media_vars), len(media_vars)))
def optimum_func():
optimum = pysolnp.solve(
obj_func=optimize_budget,
par_start_value=x0,
par_lower_limit=list(np.repeat(0, len(media_vars))),
par_upper_limit=list(np.repeat(1, len(media_vars))),
eq_func=cons_f,
eq_values=[1],
max_major_iter=10000,
max_minor_iter=10000)
return(optimum)
def optimize_budget(x):
revenue = []
# Здесь надо посоветоваться, ведь мы сразу годовой бюджет в модель пихаем, а обучалось на месяцах
# Calculate revenues for all channels -> sum it up
# print(budget)
if model_type == 'exp':
# print(x)
for i, col in list(zip(range(len(media_vars)), media_vars)):
# Calculate revenue for the channel
revenue.append(resp_func_dict[col](budget * x[i]))
# revenue.append(build_poly(budget * x[i],resp_func_dict[col]))
# revenue.append(x[i]**2)
revenue = sum(revenue)
# print(revenue)
# Set optimisation function
return -(revenue)
def cons_f(x):
return [sum(x)]
res = optimum_func()
for x in res.optimum:
row.append(x*budggg)
row.append(res.solve_value)
optimised_budget.loc[row_n] = row
row_n += 1
optimised_budget['profit'] = -optimised_budget['profit']
TV_1 TV_2 TV_3 TV_4 TV_5 TV_6 TV_7 TV_8 TV_9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
optimal_budget_plot(optimised_budget.fillna(method='ffill'))
opt_rev_plot(optimised_budget)
pip install streamlit
Collecting streamlit
Downloading streamlit-0.88.0-py2.py3-none-any.whl (8.0 MB)
|████████████████████████████████| 8.0 MB 4.7 MB/s eta 0:00:01
Requirement already satisfied: tornado>=5.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (6.1)
Requirement already satisfied: pandas>=0.21.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (1.2.4)
Collecting pyarrow
Downloading pyarrow-5.0.0-cp38-cp38-macosx_10_13_x86_64.whl (17.6 MB)
|████████████████████████████████| 17.6 MB 4.5 MB/s eta 0:00:01
Collecting validators
Downloading validators-0.18.2-py3-none-any.whl (19 kB)
Requirement already satisfied: attrs in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (21.2.0)
Collecting blinker
Downloading blinker-1.4.tar.gz (111 kB)
|████████████████████████████████| 111 kB 6.2 MB/s eta 0:00:01
Requirement already satisfied: numpy in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (1.19.5)
Requirement already satisfied: packaging in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (20.9)
Requirement already satisfied: cachetools>=4.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (4.2.2)
Collecting altair>=3.2.0
Downloading altair-4.1.0-py3-none-any.whl (727 kB)
|████████████████████████████████| 727 kB 6.5 MB/s eta 0:00:01
Requirement already satisfied: requests in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (2.25.1)
Collecting astor
Downloading astor-0.8.1-py2.py3-none-any.whl (27 kB)
Requirement already satisfied: pillow>=6.2.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (8.2.0)
Requirement already satisfied: python-dateutil in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (2.8.1)
Collecting base58
Downloading base58-2.1.0-py3-none-any.whl (5.6 kB)
Collecting tzlocal
Downloading tzlocal-3.0-py3-none-any.whl (16 kB)
Requirement already satisfied: protobuf!=3.11,>=3.6.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from streamlit) (3.16.0)
Collecting pydeck>=0.1.dev5
Downloading pydeck-0.7.0-py2.py3-none-any.whl (4.3 MB)
|████████████████████████████████| 4.3 MB 6.1 MB/s eta 0:00:01
Collecting click<8.0,>=7.0
Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
|████████████████████████████████| 82 kB 2.1 MB/s eta 0:00:011
Collecting toml
Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting gitpython!=3.1.19
Downloading GitPython-3.1.18-py3-none-any.whl (170 kB)
|████████████████████████████████| 170 kB 5.1 MB/s eta 0:00:01
Requirement already satisfied: entrypoints in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from altair>=3.2.0->streamlit) (0.3)
Requirement already satisfied: jinja2 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from altair>=3.2.0->streamlit) (3.0.0)
Collecting toolz
Downloading toolz-0.11.1-py3-none-any.whl (55 kB)
|████████████████████████████████| 55 kB 4.3 MB/s eta 0:00:01
Requirement already satisfied: jsonschema in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from altair>=3.2.0->streamlit) (3.2.0)
Collecting gitdb<5,>=4.0.1
Downloading gitdb-4.0.7-py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 4.0 MB/s eta 0:00:01
Collecting smmap<5,>=3.0.1
Downloading smmap-4.0.0-py2.py3-none-any.whl (24 kB)
Requirement already satisfied: pytz>=2017.3 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from pandas>=0.21.0->streamlit) (2021.1)
Requirement already satisfied: six>=1.9 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from protobuf!=3.11,>=3.6.0->streamlit) (1.15.0)
Requirement already satisfied: ipykernel>=5.1.2 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from pydeck>=0.1.dev5->streamlit) (5.3.4)
Requirement already satisfied: traitlets>=4.3.2 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from pydeck>=0.1.dev5->streamlit) (5.0.5)
Requirement already satisfied: ipywidgets>=7.0.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from pydeck>=0.1.dev5->streamlit) (7.6.3)
Requirement already satisfied: appnope in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.1.2)
Requirement already satisfied: jupyter-client in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (6.1.12)
Requirement already satisfied: ipython>=5.0.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (7.22.0)
Requirement already satisfied: setuptools>=18.5 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (52.0.0.post20210125)
Requirement already satisfied: backcall in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.2.0)
Requirement already satisfied: jedi>=0.16 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.17.0)
Requirement already satisfied: decorator in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (4.4.2)
Requirement already satisfied: pickleshare in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.7.5)
Requirement already satisfied: pexpect>4.3 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (4.8.0)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (3.0.17)
Requirement already satisfied: pygments in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (2.9.0)
Requirement already satisfied: widgetsnbextension~=3.5.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (3.5.1)
Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.0.0)
Requirement already satisfied: nbformat>=4.2.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (5.1.3)
Requirement already satisfied: parso>=0.7.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from jedi>=0.16->ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.8.2)
Requirement already satisfied: MarkupSafe>=2.0.0rc2 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from jinja2->altair>=3.2.0->streamlit) (2.0.1)
Requirement already satisfied: ipython-genutils in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbformat>=4.2.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.2.0)
Requirement already satisfied: jupyter-core in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbformat>=4.2.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (4.7.1)
Requirement already satisfied: pyrsistent>=0.14.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from jsonschema->altair>=3.2.0->streamlit) (0.17.3)
Requirement already satisfied: ptyprocess>=0.5 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from pexpect>4.3->ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.7.0)
Requirement already satisfied: wcwidth in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=5.0.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.2.5)
Requirement already satisfied: notebook>=4.4.1 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (6.4.0)
Requirement already satisfied: terminado>=0.8.3 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.9.4)
Requirement already satisfied: pyzmq>=17 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (20.0.0)
Requirement already satisfied: argon2-cffi in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (20.1.0)
Requirement already satisfied: nbconvert in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (6.0.7)
Requirement already satisfied: Send2Trash>=1.5.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.5.0)
Requirement already satisfied: prometheus-client in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.10.1)
Requirement already satisfied: cffi>=1.0.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.14.5)
Requirement already satisfied: pycparser in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from cffi>=1.0.0->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (2.20)
Requirement already satisfied: bleach in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (3.3.0)
Requirement already satisfied: testpath in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.4.4)
Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.5.3)
Requirement already satisfied: mistune<2,>=0.8.1 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.8.4)
Requirement already satisfied: pandocfilters>=1.4.1 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.4.3)
Requirement already satisfied: defusedxml in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.7.1)
Requirement already satisfied: jupyterlab-pygments in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.1.2)
Requirement already satisfied: async-generator in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.10)
Requirement already satisfied: nest-asyncio in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.5.1)
Requirement already satisfied: webencodings in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.5.1)
Requirement already satisfied: pyparsing>=2.0.2 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from packaging->streamlit) (2.4.7)
Requirement already satisfied: chardet<5,>=3.0.2 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from requests->streamlit) (4.0.0)
Requirement already satisfied: idna<3,>=2.5 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from requests->streamlit) (2.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from requests->streamlit) (1.26.4)
Requirement already satisfied: certifi>=2017.4.17 in /Users/sokolov/opt/anaconda3/lib/python3.8/site-packages (from requests->streamlit) (2020.12.5)
Collecting backports.zoneinfo
Downloading backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl (35 kB)
Building wheels for collected packages: blinker
Building wheel for blinker (setup.py) ... done
Created wheel for blinker: filename=blinker-1.4-py3-none-any.whl size=13451 sha256=ce7509e9a90ce5e78ae0766b3bcf562cb474d949dbc888d627e6940ec718aefa
Stored in directory: /Users/sokolov/Library/Caches/pip/wheels/b7/a5/68/fe632054a5eadd531c7a49d740c50eb6adfbeca822b4eab8d4
Successfully built blinker
Installing collected packages: smmap, toolz, gitdb, backports.zoneinfo, validators, tzlocal, toml, pydeck, pyarrow, gitpython, click, blinker, base58, astor, altair, streamlit
Attempting uninstall: click
Found existing installation: click 8.0.1
Uninstalling click-8.0.1:
Successfully uninstalled click-8.0.1
Successfully installed altair-4.1.0 astor-0.8.1 backports.zoneinfo-0.2.1 base58-2.1.0 blinker-1.4 click-7.1.2 gitdb-4.0.7 gitpython-3.1.18 pyarrow-5.0.0 pydeck-0.7.0 smmap-4.0.0 streamlit-0.88.0 toml-0.10.2 toolz-0.11.1 tzlocal-3.0 validators-0.18.2
Note: you may need to restart the kernel to use updated packages.